#pragma once

#include "stdafx.h"


 #include <OgreFrameListener.h>
 #include <Ogre.h>
 #include <OIS/OIS.h>
 #include <list>
 #include <vector>


 
 using namespace Ogre;
 using namespace std;
 
 class Console: public Singleton<Console>, FrameListener
 {
 public:
    Console();
    ~Console();
 
    void   init(Ogre::Root *root);
    void   shutdown();
 
    void   setVisible(bool visible);
    bool   isVisible(){return visible;}
 
    void   print(const String &text);
 
    virtual bool frameStarted(const Ogre::FrameEvent &evt);
    virtual bool frameEnded(const Ogre::FrameEvent &evt);
 
    void onKeyPressed(const OIS::KeyEvent &arg);
 
    void addCommand(const String &command, void (*)(std::vector<String>&));
    void removeCommand(const String &command);
 
    //log
    void messageLogged( const String& message, LogMessageLevel lml, bool maskDebug, const String &logName ) {print(logName+": "+message);}
 private:
    bool            visible;
    bool            initialized;
    Root         *root;
    SceneManager   *scene;
    Rectangle2D   *rect;
    SceneNode      *node;
    OverlayElement *textbox;
    Overlay      *overlay;
 
    float            height;
    bool            update_overlay;
    int               start_line;
    std::list<String>      lines;
    String            prompt;
    std::map<String,void (*)(std::vector<String>&)>  commands;
 };